from fastapi import FastAPI, Body
from pydantic import BaseModel
import uvicorn

app = FastAPI()


@app.put("/test")
def put_test(data: str = Body(...)):
    print("recv:", data)
    return {"recv_data": data}


class RequestStr(BaseModel):
    data: str = None


@app.put("/test_request_str")
def put_test2(data: RequestStr):
    print("recv:", data.data)
    return {"recv_data": data}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)
